import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

@WebServlet(name="ServletDemo04",urlPatterns = "/S4")
public class ServletDemo04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        ServletContext context=this.getServletContext();
        Enumeration<String> parameterNames = context.getInitParameterNames();
        out.println("all the paramName and paramValue are following"+"<br>");

        while(parameterNames.hasMoreElements()){
            String name=parameterNames.nextElement();
            String value=context.getInitParameter(name);
            out.println(name + ":" + value +"<br>");

        }
    }
}
